package LC;

/**
 * https://leetcode.com/problems/factorial-trailing-zeroes/description/
 * Given an integer n, return the number of trailing zeroes in n!.
 * Note: Your solution should be in logarithmic time complexity.
 * Credits:
 * Special thanks to @ts for adding this problem and creating all test cases.
 */
public class LC_172_FactorialTrailingZeroes_Math {
    public static void main(String[] args) {
        System.out.println(Solution.trailingZeroes(75));
    }

    static class Solution {
        static int trailingZeroes(int n) {
            int result = 0;
            for (long i = 5; i <= (long) n; i *= 5) {
                result += n / i;
            }
            return result;
        }
    }
}